<!doctype html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../assert_selection.js"></script>
<script>
test(() => {
  assert_own_property(window, 'testRunner', 'This test requires testRunner');

  assert_selection(
  [
    '<div contenteditable><a href="http://www.example.com/">^text|</a></div>',
    '<a href="http://www.example2.com/" id="other">link</a>'
  ].join(''),
  selection => {
    const other = selection.document.getElementById('other');
    other.focus();
    testRunner.execCommand('unlink');
    assert_equals(selection.document.activeElement, other);
  },
  [
    '<div contenteditable><a href="http://www.example.com/">^text|</a></div>',
    '<a href="http://www.example2.com/" id="other">link</a>'
  ].join(''));
}, 'Unlink with unfocused selection in contenteditable div');
</script>
